from selenium import webdriver
from selenium.webdriver.common.by import By
from webdriver_manager.chrome import ChromeDriverManager
import time

chrome_options = webdriver.ChromeOptions()
chrome_options.add_experimental_option('detach', True)
dirver = webdriver.Chrome(ChromeDriverManager().install(), options=chrome_options)

dirver.get("https://bqgda.cc/")

# 定位元素
dirver.find_element(By.CLASS_NAME, "loginbtn").click()
time.sleep(1)
dirver.find_element(By.ID, "username").send_keys("17720021621")
dirver.find_element(By.ID, "password").send_keys("123456")
dirver.find_element(By.XPATH, '//input[@value="确认登录"]').click()

time.sleep(2)

# 获取数据
box_list = dirver.find_elements(By.XPATH, '//div[@class="box"]')
for box in box_list:
    title = box.find_element(By.XPATH, './/h4').text
    author = box.find_element(By.XPATH, './/div[@class="author"]').text
    update1 = box.find_element(By.XPATH, './/div[@class="update"][1]').text
    update2 = box.find_element(By.XPATH, './/div[@class="update"][2]').text
    print(title,author,update1,update2)
